<input id="status" name="status" type="hidden" value="{$params.status}"/>
<input id="p" name="p" type="hidden" value="{$p}"/>
<table class="table table-bordered">
    <thead>
    <tr>
        <th width="6%">资讯ID</th>
        <th>标题</th>
        <th width="7%">作者</th>
        <th width="7%">资讯类型</th>
        <th width="7%">资讯来源</th>
        <th width="6%">主频道</th>
        <th width="6%">子频道</th>
        <th width="7%">是否精华</th>
        <th width="12%">采集时间</th>
        <th width="12%">发布时间</th>
        <th width="6%">状态</th>
        <th width="11%">操作</th>
    </tr>
    </thead>
    <tbody>
    <volist name="article" id="vo" key="k">
        <tr>
            <td>{$vo.article_id}</td>
            <td>{$vo.article_title}</td>
            <td>{$vo.author}</td>
            <td><if condition="$vo['type'] eq 1">原创<else/>转载</if></td>
            <td><if condition="$vo['type'] neq 1">{$vo.from_name}<else/>车来车往</if></td>
            <td>{$cate[$vo['category_id']]['category_title']}</td>
            <td>{$cate[$vo['child_id']]['category_title']}</td>
            <td>
                <if condition="$vo.is_top eq 1">是
                    <else/>
                    否
                </if>
            </td>
            <td>
                {$vo.create_time|date="Y-m-d H:i",###}
            </td>
            <td>
                <if condition="!empty($vo['cron_time']) && $vo['status'] == 3">
                    {$vo.cron_time|date="Y-m-d H:i",###}
                    <elseif condition="!empty($vo['publish_time'])"/>
                    {$vo.publish_time|date="Y-m-d H:i",###}
                    <else />
                    --
                </if>
            </td>
            <td>
                <if condition="$vo.status eq 0">
                    删除
                    <elseif condition="$vo.status eq 1"/>
                    已发布
                    <elseif condition="$vo.status eq 2"/>
                    未发布
                    <elseif condition="$vo.status eq 3"/>
                    预发布
                </if>
            </td>
            <td>
                <if condition="$vo['status'] neq 1">
                    <a target="_blank" href="/ArticleCrawler/editArticleCrawler/id/{$vo.article_id}">编辑</a> |
                    <a href="javascript:;" onclick="openwin('/ArticleCrawler/show/id/{$vo.article_id}');">预览</a>
                    | <a href="javascript:;" onclick="publish({$vo.article_id});">发布</a>
                    <else />
                    --
                </if>
            </td>
        </tr>
    </volist>
    </tbody>
</table>
<div class="pageFaye">
    <div class="pager">{$page}</div>
    <div class="clear"></div>
</div>

<div class="deparHover" style="height: 200px;">
    <h4>资讯采集预发布</h4>
    <label>
        发布时间：<input type="text" id="publish_time" name="publish_time" value="" readonly="" placeholder="发布时间">
    </label>
    <input type="hidden" id="article_id" value="" />
    <div class="deparBtn">
        <input type="button" value="确定" class="deparQue" id="submitPublish">
        <input type="button" value="取消" id="closePublis">
    </div>
</div>


<script>
    $(function(){
        $('#closePublis').click(function(){
            $('.deparHover').hide();
            $('#article_id').val('');
            $('#publish_time').val('');
        });
        $('#submitPublish').click(function(){
            var article_id = $('#article_id').val();
            var publish_time = $('#publish_time').val();
            if (!article_id) {
                return false;
            }
            if (!publish_time) {
                alert('请选择发布时间!');
                return false;
            }
            $.post('/ArticleCrawler/articleCronPublish', {article_id:article_id, publish_time:publish_time}, function (data) {
                if (data.code == '200') {
                    alert(data.msg);
                    $('.deparHover').hide();
                    $('#article_id').val('');
                    $('#publish_time').val('');
                    searchList();
                } else{
                    alert(data.msg);
                }
            }, 'json');

        });
    });
    $("#publish_time").ymdateplugin({
        showTimePanel: true,
        changeMonth: true,
        changeYear: true,
        gotoCurrent: true,
        minDate: "{$date}"
    });
    function showPublisBox(id){
        $('.deparHover').show();
        $('#article_id').val(id);
    }
    function publish(id) {
        if (confirm('确定要发布该篇文章么?')) {
            $.post('/ArticleCrawler/articleCrawlerPublish', {id: id, status: 1}, function (data) {
                if (data.code == 200) {
                    btn_alert('发布成功');
                    searchList();
                } else {
                    shibai_alert('发布失败请重试');
                }
            }, 'json');
        }
    }

    function openwin(url) {
        var a = document.createElement("a");
        a.setAttribute("href", url);
        a.setAttribute("target", "_blank");
        a.setAttribute("id", "openwin");
        document.body.appendChild(a);
        a.click();
    }

</script>